# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $ app-text/prince/prince-9.0-r5.ebuild,v 1.1 2014/06/09 16:45:00 itspec.ru Exp $

EAPI="3"

inherit eutils

LINUX_PR="r5"
FREEBSD_PR="r5"

DESCRIPTION="Converts XML/HTML to PDF."

HOMEPAGE="http://www.princexml.com/"

SRC_URI="x86? ( !static? ( http://www.princexml.com/download/${PN}-${PV}${LINUX_PR}-linux.tar.gz ) )
         x86? ( static? ( http://www.princexml.com/download/${PN}-${PV}${LINUX_PR}-linux-static.tar.gz ) )
         amd64? ( !static? ( http://www.princexml.com/download/${PN}-${PV}${LINUX_PR}-linux-amd64.tar.gz ) )
         amd64? ( static? ( http://www.princexml.com/download/${PN}-${PV}${LINUX_PR}-linux-amd64-static.tar.gz ) )
         x86-fbsd? ( !static? ( http://www.princexml.com/download/${PN}-${PV}${FREEBSD_PR}-freebsd82.tar.gz ) )
         x86-fbsd? ( static? ( http://www.princexml.com/download/${PN}-${PV}${FREEBSD_PR}-freebsd82-static.tar.gz ) )
         "
LICENSE="Prince-EULA"
RESTRICT="mirror"
SLOT="0"
KEYWORDS="~x86 ~amd64 ~x86-fbsd"
IUSE="+static"

DEPEND=""
RDEPEND=""

src_unpack() {
    unpack ${A}
    S="${WORKDIR}/$(ls ${WORKDIR})"
}

src_prepare() {
    into /opt
    cat > "${S}"/prince <<EOF
#! /bin/sh

exec "${DESTTREE}/${PN}/bin/${PN}" --prefix="${DESTTREE}/${PN}" "\$@"
EOF
}

src_install() {
    exeinto /opt/bin
    doexe "${S}"/prince || die

    insinto /opt/${PN}
    doins -r "${S}"/lib/"${PN}"/* || die
    into /opt
    fperms "0755" "${DESTTREE}/${PN}/bin/${PN}" || die

    dodoc LICENSE README
}
